package com.pgytesting.secondhandcar.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.pgytesting.secondhandcar.model.OrderName;
import com.pgytesting.secondhandcar.model.ReviewInformation;
import com.pgytesting.secondhandcar.service.OrderNameService;
import com.pgytesting.secondhandcar.service.ReviewInformationService;
import com.pgytesting.secondhandcar.vo.Parameters;
import com.pgytesting.secondhandcar.vo.ResponseMessage;

import lombok.extern.slf4j.Slf4j;


@Slf4j
@RestController
@RequestMapping("/admin/operatorsExamine")
public class OperatorsExamineController {

	@Autowired
	private OrderNameService orderNameService;
	@Autowired
	private ReviewInformationService ReviewInformationService;
	
	
	/**
	 * 获取待审核征信材料列表
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/queryCreditReporting",method = RequestMethod.POST)
	public ResponseMessage queryCreditReporting() {
		try {
			return ResponseMessage.successResponse(orderNameService.queryCreditReporting());
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取征信材料列表出现异常");
		}
	}
	
	/**
	 * 获取待审核合同材料列表
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getContractExamineList",method = RequestMethod.POST)
	public ResponseMessage getContractExamineList() {
		try {
			return ResponseMessage.successResponse(ReviewInformationService.queryExamineContract());			
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取合同材料列表出现异常");
		}
	}
	
	/**
	 * 获取待审核放款材料列表
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/getLendingMaterialsExamineList",method = RequestMethod.POST)
	public ResponseMessage getLendingMaterialsExamineList() {
		try {
			return ResponseMessage.successResponse(ReviewInformationService.queryExamineLoanMaterial());			
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取放款材料列表出现异常");
		}
	}
	
	/**
	 * 运营商审核征信通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineCreditAdopt",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineCreditAdopt(@RequestBody OrderName orderName) {
		try {
			orderNameService.operatorsExamineCredit(orderName.getId(),Parameters.ORDER_24005,0);
			return ResponseMessage.successResponse("审核征信通过成功");			
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("审核征信通过出现异常");
		}
	}
	
	/**
	 * 运营商审核征信驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineCreditRebut",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineCreditRebut(@RequestBody OrderName orderName) {
		try {
			orderNameService.operatorsExamineCredit(orderName.getId(),Parameters.ORDER_24006,2);
			return ResponseMessage.successResponse("审核征信驳回成功");			
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("审核征信驳回出现异常");
		}
	}
	
	/**
	 * 资方审核征信通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/managementExamineCreditAdopt",method = RequestMethod.POST)
	public ResponseMessage managementExamineCreditAdopt(@RequestBody OrderName orderName) {
		try {
			return orderNameService.managementExamineCredit(orderName.getId(),Parameters.ORDER_25001,0);			
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("审核征信通过出现异常");
		}
	}
	
	/**
	 * 资方审核征信驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/managementExamineCreditRebut",method = RequestMethod.POST)
	public ResponseMessage managementExamineCreditRebut(@RequestBody OrderName orderName) {
		try {
			return orderNameService.managementExamineCredit(orderName.getId(),Parameters.ORDER_24007,2);		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("审核征信驳回出现异常");
		}
	}
	
	/**
	 * 运营商审核合同驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineContractRebut",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineContractRebut(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineContract(reviewInformation.getId(),Parameters.ORDER_26003,2);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核合同驳回出现异常");
		}
	}
	
	/**
	 * 运营商审核合同拒绝
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineContractRefuse",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineContractRefuse(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineContract(reviewInformation.getId(),Parameters.ORDER_26004,1);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核合同拒绝出现异常");
		}
	}
	
	/**
	 * 运营商审核合同退回风控重审
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineContractGoBack",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineContractGoBack(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineContract(reviewInformation.getId(),Parameters.ORDER_26005,4);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核合同退回风控重审出现异常");
		}
	}
	
	/**
	 * 运营商审核合同补件
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineContractPatch",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineContractPatch(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineContract(reviewInformation.getId(),Parameters.ORDER_26006,3);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核合同补件出现异常");
		}
	}
	
	/**
	 * 运营商审核合同通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineContractAdopt",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineContractAdopt(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineContract(reviewInformation.getId(),Parameters.ORDER_26007,0);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核合同通过出现异常");
		}
	}
	
	/**
	 * 运营商复审合同通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsReviewContractAdopt",method = RequestMethod.POST)
	public ResponseMessage operatorsReviewContractAdopt(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsReviewContract(reviewInformation.getId(),Parameters.ORDER_27001,0);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("获取贷款列表出现异常");
		}
	}
	
	/**
	 * 运营商复审合同驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsReviewContractRebut",method = RequestMethod.POST)
	public ResponseMessage operatorsReviewContractRebut(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsReviewContract(reviewInformation.getId(),Parameters.ORDER_26008,2);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商复审合同驳回出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialRebut",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialRebut(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27003,2);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料驳回出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料拒绝
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialRefuse",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialRefuse(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27004,1);	
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料拒绝出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料垫付
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialAdvance",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialAdvance(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27005,7);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料垫付出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料退回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialGoBack",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialGoBack(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27006,4);		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料退回出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料补件
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialPatch",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialPatch(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27007,3);		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料补件出现异常");
		}
	}
	
	/**
	 * 运营商审核放款材料通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsExamineLoanMaterialAdopt",method = RequestMethod.POST)
	public ResponseMessage operatorsExamineLoanMaterialAdopt(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27008,0);		
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商审核放款材料通过出现异常");
		}
	}
	
	/**
	 * 运营商复审放款材料驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsReviewLoanMaterialReject",method = RequestMethod.POST)
	public ResponseMessage operatorsReviewLoanMaterialReject(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsReviewLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27009,2);	
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商复审放款材料驳回出现异常");
		}
	}
	
	/**
	 * 运营商复审放款材料通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/operatorsReviewLoanMaterialAdopt",method = RequestMethod.POST)
	public ResponseMessage operatorsReviewLoanMaterialAdopt(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.operatorsReviewLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27010,0);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("运营商复审放款材料通过出现异常");
		}
	}
	
	/**
	 * 资方审核放款材料驳回
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/managementExamineLoanMaterialReject",method = RequestMethod.POST)
	public ResponseMessage managementExamineLoanMaterialReject(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.managementExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27011,2);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse("资方审核放款材料驳回出现异常");
		}
	}
	
	/**
	 * 资方审核放款材料通过
	 * @param orderName
	 * @return
	 */
	@RequestMapping(value = "/managementExamineLoanMaterialAdopt",method = RequestMethod.POST)
	public ResponseMessage managementExamineLoanMaterialAdopt(@RequestBody ReviewInformation reviewInformation) {
		try {
			return ReviewInformationService.managementExamineLoanMaterial(reviewInformation.getId(),Parameters.ORDER_27012,0);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseMessage.errorResponse(" 资方审核放款材料通过出现异常");
		}
	}
}
